package controller;

import javax.swing.JFrame;
import javax.swing.JPanel;

import client.Client;
import entity.Order;

import boundary.MainGui;
import boundary.OneTimeOrderInAdvanceWin;
import boundary.SubscriptionOrderGui;
import boundary.ViewOrCancelOrders;

public class OneTimeOrderInAdvance {
	public void getOrder()
	{
		JFrame frame=MainGui.getFrame();
		OneTimeOrderInAdvanceWin subOrder=new OneTimeOrderInAdvanceWin();
		subOrder.setLastPanel((JPanel)frame.getContentPane());
		subOrder.setFrame(frame);
		frame.setContentPane(subOrder);
		frame.setVisible(true);
	}
	public void viewOrder()
	{
		Order orders []=Client.getOrders();
		int n=0;
		for (int i=0; i<orders.length; i++)
			if (orders[i].getCustomerID().equals(Client.getLoggedIn()))
				n++;
		Order ordersById[]=new Order[n];
		int j=0;
		for (int i=0; i<orders.length; i++)
			if (orders[i].getCustomerID().equals(Client.getLoggedIn()))
			{
				ordersById[j]=orders[i];
				j++;
			}
		JFrame frame=MainGui.getFrame();
		ViewOrCancelOrders subOrder=new ViewOrCancelOrders(ordersById);
		subOrder.setLastPanel((JPanel)frame.getContentPane());
		subOrder.setFrame(frame);
		frame.setContentPane(subOrder);
		frame.setVisible(true);
		
	}

}
